// 百度AI开放平台鉴权token获取服务
export async function getVoiceToken() {
        return new Promise((resolve, reject) => {
            uni.request({
                url: 'https://aip.baidubce.com/oauth/2.0/token',
                method: 'POST',
                data: {
                    client_id: '75zMrBiQ4hgCFE4R5WdV2G5U',
                    client_secret: 'Q0ae4f1IkAzkydBjsNZhzW8V7G7UrZTh',
                    grant_type: 'client_credentials'
                },
                header: {
                    'Content-Type': 'application/x-www-form-urlencoded'
                },
                success: (res) => {
                    if (res.statusCode === 200 && res.data.access_token) {
                        resolve(res.data);
                    } else {
                        reject(new Error(`获取token失败: ${res.data.error_description || '未知错误'}`));
                    }
                },
                fail: (err) => {
                    reject(new Error(`网络请求失败: ${err.errMsg}`));
                }
            });
        });
    }
